<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }
        
        #imgs {
            width: 300px;
            height: 500px;
            position: absolute;
            top: 0;
            left: 0;
        }
        
        #xiBox {
            position: absolute;
            width: 100px;
            height: 100px;
            background-color: rgba(255, 255, 255, .6);
            cursor: move;
            z-index: 2;
            display: none;
        }
        
        .box {
            position: relative;
            margin-left: 10px;
            margin-top: 10px;
        }
        
        #bigImg {
            position: absolute;
            right: 10px;
            top: 0;
            height: 600px;
            width: 1000px;
            border: 1px solid black;
            overflow: hidden;
            /* display: none; */
        }
        
        #toImg {
            position: absolute;
            width: 2000px;
            height: 1200px;
            top: 0px;
            left: 0px;
        }
    </style>

</head>

<body>
    <div class="box">
        <div id="xiBox"></div>
        <img id="imgs" src="../images/b4d272ef900f03b005a75804a69876cd0a7761b6.png">
    </div>

    <div id="bigImg">
        <img id="toImg" src="../images/b4d272ef900f03b005a75804a69876cd0a7761b6.png">
    </div>
</body>
<script src="../js/jquery.min.js"></script>
<script>
    $(() => {
        var imgs = $('#imgs');
        var xiBox = $('#xiBox');
        $('.box').hover(function() {
                xiBox.show();
                $(this).mousemove(function(ev) {
                    var tops = ev.pageY - (xiBox.height() / 2);
                    var lefts = ev.pageX - (xiBox.width() / 2);
                    if (tops <= 0) {
                        tops = 0;
                    }
                    if (tops > (imgs.height() - xiBox.height())) {
                        tops = (imgs.height() - xiBox.height());
                    }

                    if (lefts > (imgs.width() - xiBox.width())) {
                        lefts = (imgs.width() - xiBox.width());
                    }
                    if (lefts < 0) {
                        lefts = 0;
                    }

                    $('#toImg').css({A
                        top: -tops * ($('#toImg').height() - $('#bigImg').height()) / ($('#imgs').height() - xiBox.height()),
                        left: -lefts * ($('#toImg').width() - $('#bigImg').width()) / ($('#imgs').width() - xiBox.width()),
                    })

                    xiBox.css({
                        top: tops,
                        left: lefts,
                    })
                })
            },
            function() {
                xiBox.hide();
            })



    })
</script>

</html>